package com.jsm.tf.controller;

import com.jsm.tf.director.Director;
import com.jsm.tf.entity.User;
import com.jsm.tf.service.UserService;
import com.jsm.tf.view.RegisterView;
import com.jsm.tf.view.RoomListView;
import com.jsm.tf.view.dialog.TFDialog;
import de.felixroske.jfxsupport.FXMLController;
import de.felixroske.jfxsupport.GUIState;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import org.springframework.beans.factory.annotation.Autowired;

@FXMLController
public class LoginController {
    @Autowired
    private Director director;
    @FXML
    private TextField password;
    @FXML
    private Button login;
    @FXML
    private TextField username;
    @Autowired
    private UserService userService;

    public void login(MouseEvent mouseEvent) {
        userService.login(this.username.getText(), this.password.getText());
    }

    public void register(MouseEvent mouseEvent) {
        director.showView(RegisterView.class);
    }
}
